#ifndef LINKQUALITYECHO_H
#define LINKQUALITYECHO_H

#include <QDialog>
#include <QThread>

class QUdpSocket;
class QPushButton;

class updateGPS : public QThread
{
    Q_OBJECT

public:
    updateGPS()
    {
        stopped = false;
    }
    virtual ~updateGPS() {}
    void stop();
    void run1();

signals:
    void updateData(QString data);

private:
    int openPort();

protected:
    void run();

private:
    bool stopped;
};

class UDPServer : public QThread
{
    Q_OBJECT

public:
    UDPServer();
    virtual ~UDPServer(){}
    void stop();

signals:
    void receiveCMD(QByteArray *data);

private slots:
    void processPendingDatagrams();

private:
    QUdpSocket *receiveSocket;
    bool stopped;
};

class LinkQualityEcho : public QDialog
{
    Q_OBJECT

public:
    LinkQualityEcho(QWidget *parent = 0);

private slots:
    //void startOrStop();
    void updateGPSData(QString gps);
    void sendReply(QByteArray *data);

protected:
    void closeEvent(QCloseEvent *);

private:
    void loadGUI();

private:
    QPushButton *startButton;
    QPushButton *closeButton;

    QString gps;
    updateGPS *thread;
    UDPServer *server;

    bool threadIsRuning;
    int s;
};

#endif // LINKQUALITYECHO_H
